//
//  UIBarButtonItem+extension.swift
//  我的微博
//
//  Created by shmily on 15/8/7.
//  Copyright © 2015年 Stanford-IOS8-Swift-shmilyAshen. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(imgName: String,target: AnyObject?,action: String?) {
        let btn = UIButton()
        btn.setImage(UIImage(named: imgName), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: imgName + "_highlighted"), forState: UIControlState.Highlighted)
        
        if let actionName = action {
            
            btn.addTarget(target, action: Selector(actionName), forControlEvents: UIControlEvents.TouchUpInside)
        }
        btn.sizeToFit()
        
        self.init(customView: btn)
        
    }
}
